﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LiveResults
{
    public enum RunnerStatus
    {
        OK = 0,
        DID_NOT_START = 4,
        OVERTIME = 3,
        MISSING_PUNCH = 1,
        DISQUALIFIED = 2,
        WALK_OVER = 5,
        MOVED_UP = 6,
        STARTED = 10,
        NOT_ACTIVATED = 11
    }

    public delegate void ResultDelegate(int id, int SI, string firstName,string lastName, string club, string Class, int start, int time, RunnerStatus status, List<ResultStruct> splits);
    public delegate void ClassDelegate(string className, int courseLength, int numControls, int order, List<ControlStruct> splitControls);
    public class BaseParser
    {
        public event ResultDelegate OnResult;
        public event MainApp.logDelegate OnLogMessage;
        public event ClassDelegate OnClass;

        protected void FireOnResult(int id, int SI, string firstName, string lastName, string club, string Class, int start, int time, RunnerStatus status, List<ResultStruct> results)
        {
            ResultDelegate dlg = OnResult;
            if (dlg != null)
            {
                dlg(id, SI, firstName, lastName, club, Class, start, time, status, results);
            }
        }

        protected void FireOnClass(string className, int courseLength, int numControls, int order, List<ControlStruct> splitControls)
        {
            ClassDelegate delg = OnClass;
            if (delg != null)
                delg(className, courseLength, numControls, order, splitControls);
        }

        protected void FireLogMsg(string msg)
        {
            MainApp.logDelegate dlg = OnLogMessage;
            if (dlg != null)
                dlg(msg);
        }
    }
}
